#!/bin/sh
# 软件列表配置文件


glabal_github_proxy_url=""
# glabal_github_proxy_url="https://github.moeyy.xyz/"
# glabal_github_proxy_url="https://gitapi.simplehac.top/"

# 包含软件名称、描述和安装命令
sw_vers -productVersion | awk -F. '{
    if($1==16) print "Tahoe "$0;
    else if($1==15) print "Sequoia "$0;
    else if($1==14) print "Sonoma "$0;
    else if($1==13) print "Ventura "$0;
    else if($1==12) print "Monterey "$0;
    else if($1==11) print "Big Sur "$0;
    else if($1==10 && $2==15) print "Catalina "$0;
    else if($1==10 && $2==14) print "Mojave "$0;
    else if($1==10 && $2==13) print "High Sierra "$0;
    else print "未知版本 "$0
}'
# # 获取核显信息（如 Intel HD 3000）
gpu_info=$(system_profiler SPDisplaysDataType 2>/dev/null)
# # 检查是否找到核显
# if echo "$gpu_info" | grep -qi "Intel HD Graphics 3000"; then
#     HD_version=""
# fi

# 获取核显版本号
gpu_version=$(
  # system_profiler SPDisplaysDataType 2>/dev/null | \
  #   grep -Eo "Intel HD Graphics [0-9]{4}" | \
  #   awk '{print $4}' | \
  #   head -n1
  system_profiler SPDisplaysDataType 2>/dev/null | \
    grep -Eo "Intel (HD|Iris|Iris Pro) Graphics [0-9]{3,4}" | \
    awk '{print $NF}' | \
    head -n1
)
# 检查结果并输出
# if [ -n "$gpu_version" ]; then
#   echo "检测到 Intel HD Graphics $gpu_version"
# else
#   echo "未检测到 Intel HD Graphics 显卡"
# fi
[ -n "$gpu_version" ] && echo "Intel 核显版本: $gpu_version" || \
  echo "未检测到 Intel 核显"

metal_support_version=$(
  system_profiler SPDisplaysDataType 2>/dev/null | \
    grep -Eo "Metal Support: Metal [0-9]{1}" | \
    awk '{print $4}' | \
    head -n1
)
[ -n "$metal_support_version" ] && echo "Metal 支持版本: $metal_support_version" || \
  echo "未检测到 Metal 支持";metal_support_version=0;

# # 检查 Metal Support: Metal 2
# if echo "$gpu_info" | grep -qi "Metal Support: Metal 2"; then
#     metal_support_version="2"
# else
#     metal_support_version="1"
# fi
darwin_version=$(uname -r)
# Darwin 版本号格式为 <主版本>.<次版本>.<修订号>，对应 macOS 版本：
# ｜ 名称         ｜ 版本号 ｜ Darwin 内核版本 ｜
# ｜ Sonoma	     ｜ 14.x  ｜ 23.x           ｜
# ｜ Ventura     ｜ 13.x  ｜ 22.x           ｜
# ｜ Monterey    ｜ 12.x  ｜ 21.x           ｜
# ｜ Big Sur     ｜ 11.x  ｜ 20.x           ｜
# ｜ Catalina    ｜ 10.15	｜ 19.x           ｜
# ｜ Mojave      ｜ 10.14	｜ 18.x           ｜
# ｜ High Sierra ｜ 10.14	｜ 17.x           ｜
# 提取主版本和次版本号
major_version=$(echo "$darwin_version" | cut -d. -f1)
minor_version=$(echo "$darwin_version" | cut -d. -f2)

# 将版本号转换为可比较的数字（去除前导零）
major_version=$((10#$major_version))
minor_version=$((10#$minor_version))

# 判断版本范围
if [[ $major_version -eq 17 && $minor_version -le 9 ]]; then
    echo "版本在17.0-17.9.9范围内，执行策略 High Sierra"
    source "${CONFIG_DIR}/software_list_osx_highsierra.sh"  
elif [[ $major_version -eq 18 && $minor_version -le 9 ]]; then
    echo "版本在18.0-18.9.9范围内，执行策略 Mojave"
elif [[ $major_version -eq 19 && $minor_version -le 9 ]]; then
    echo "版本在19.0-19.9.9范围内，执行策略 Catalina"
elif [[ $major_version -eq 20 && $minor_version -le 9 ]]; then
    echo "版本在20.0-20.9.9范围内，执行策略 Big Sur"
elif [[ $major_version -eq 21 && $minor_version -le 9 ]]; then
    echo "版本在21.0-21.9.9范围内，执行策略 Monterey"
elif [[ $major_version -eq 22 && $minor_version -le 9 ]]; then
    echo "版本在22.0-22.9.9范围内，执行策略 Ventura"
elif [[ $major_version -eq 23 && $minor_version -le 9 ]]; then
    echo "版本在23.0-23.9.9范围内，执行策略 Sonoma"
# elif [[ $major_version -ge 18 && $major_version -le 21 ]]; then
#     if [[ $minor_version -le 9 ]]; then
#         echo "版本在18.0-21.9.9范围内，执行策略2"
#     else
#         echo "版本不在目标范围内"
#     fi
else
    echo "版本不在目标范围内"
fi


# 软件列表
#                   软件名  检查         描述        官网    指定要软件包下载        安装命令
set_software_list   "brew" \
                    "brew"  \
                    "包管理工具"  \
                    "/" \
                    "/" \
                    "/" \
                    "/bin/zsh -c '$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)'"

if [ $major_version -eq 17 ] ;then 
    set_software_list   "MacPorts" \
                        "port"  \
                        "包管理工具"  \
                        "https://www.macports.org/" \
                        "${glabal_github_proxy_url}https://github.com/macports/macports-base/releases/download/v2.11.5/MacPorts-2.11.5-10.13-HighSierra.pkg" \
                        "/" \
                        "install_software_fun1 MacPorts"
fi

set_software_list   "md5sha1sum" \
                    "md5sum" \
                    "下载工具" \
                    "/" \
                    "/" \
                    "/" \
                    "install_with_package md5sha1sum"

if [ $major_version -eq 17 ] ;then 
    set_software_list   "pkg-config" \
                        "pkg-config" \
                        "基础依赖" \
                        "https://github.com/openssl/openssl"  \
                        "https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz" \
                        "/" \
                        "install_software_source_fun1 pkg-config  cd ${OUTPUT_DIR}/pkg-config-0.29.2/pkg-config-*/ ; ./configure --with-internal-glib ; make && sudo make install"
                        # 使用内部 glib 进行配置和安装
    # macOS Serria 下可能缺少依赖： libidn2 libunistring
    # brew install libidn2 libunistring 
    # 或 sudo port install libidn2  libunistring
    set_software_list   "wget" \
                        "wget" \
                        "下载工具" \
                        "/" \
                        "https://ftp.gnu.org/gnu/wget/wget-latest.tar.gz" \
                        "/" \
                        "install_software_source_fun1 wget  cd ${OUTPUT_DIR}/wget-latest/wget-* ; ./configure;make;sudo make install;wget --version"
                        # "install_software_source_fun1 wget  tar -zxvf ${OUTPUT_DIR}/wget-latest.tar.gz -C ${OUTPUT_DIR}; cd ${OUTPUT_DIR}/wget-* ;/configure;make;sudo make install;wget --version"
else
    set_software_list   "wget" \
                        "wget" \
                        "下载工具" \
                        "/" \
                        "/" \
                        "/" \
                        "install_with_package wget"
fi

set_software_list   "axel"  \
                    "axel"  \
                    "多线程下载工具" \
                    "/"  \
                    "/"  \
                    "/"  \
                    "install_with_package axel"

set_software_list   "p7zip"  \
                    "7z"  \
                    "压缩解压"  \
                    "/" \
                    "/" \
                    "/" \
                    "install_with_package p7zip"

set_software_list   "openssh" \
                    "ssh" \
                    "加密解密工具"  \
                    "/" \
                    "/" \
                    "/" \
                    "install_with_package openssh"

if [ $major_version -eq 17 ] ;then lua_version="5.4.6";else lua_version="5.4.6";fi
set_software_list   "lua-${lua_version}" \
                    "lua" \
                    "运行环境lua（${lua_version}）" \
                    "https://www.lua.org/"  \
                    "https://www.lua.org/ftp/lua-${lua_version}.tar.gz"  \
                    "/" \
                    "install_software_source_fun1 lua-${lua_version} cd ${OUTPUT_DIR}/lua-${lua_version} make macosx test && sudo make install"

if [ $major_version -eq 17 ] ;then 
    set_software_list   "gpg" \
                        "gnupg" \
                        "加密解密工具" \
                        "https://www.gnupg.org/download/" \
                        "https://sf-west-interserver-1.dl.sourceforge.net/project/gpgosx/GnuPG-2.4.7.dmg?viasf=1"  \
                        "/" \
                        "install_software_fun1 gnupg"
else
    set_software_list   "gpg" \
                        "gnupg" \
                        "加密解密工具" \
                        "https://www.gnupg.org/download/" \
                        "https://releases.gpgtools.com/GPG_Suite-2023.3.dmg"  \
                        "/" \
                        "install_with_package gnupg"
fi
if [ $major_version -eq 17 ] ;then 
    set_software_list   "git" \
                        "git" \
                        "版本控制器" \
                        "https://git-scm.com/downloads"  \
                        "https://nchc.dl.sourceforge.net/project/git-osx-installer/git-2.33.0-intel-universal-mavericks.dmg?viasf=1"  \
                        "/" \
                        "install_software_dmg git"

    set_software_list   "git-remote-gcrypt" \
                        "/usr/local/bin/git-remote-gcrypt" \
                        "版本控制器" \
                        "https://github.com/spwhitton/git-remote-gcrypt"  \
                        "https://github.com/spwhitton/git-remote-gcrypt/archive/refs/heads/master.zip"  \
                        "/" \
                        "install_software_source_fun1 git-remote-gcrypt cd ${OUTPUT_DIR}/master/git-remote-gcrypt*/ ; ./install.sh "
else
    set_software_list   "git"  \
                        "git"  \
                        "版本控制器" \
                        "https://git-scm.com/downloads" \
                        "/"  \
                        "/"  \
                        "install_with_package git git-remote-gcrypt"
fi

set_software_list   "tig"  \
                    "tig"  \
                    "git客户端"  \
                    "/"  \
                    "/"  \
                    "/"  \
                    "install_with_package tig"

if [ $major_version -eq 17 ] ;then 
    set_software_list "lazygit" \
                      "lazygit" \
                      "Git命令行客户端" \
                      "https://github.com/jesseduffield/lazygit" \
                      "${glabal_github_proxy_url}https://github.com/jesseduffield/lazygit/releases/download/v0.42.0/lazygit_0.42.0_Darwin_x86_64.tar.gz" \
                      "/"  \
                      "install_software_fun2 lazygit ./lazygit  ~/.local/bin" 
else
    set_software_list   "lazygit" \
                        "lazygit" \
                        "git客户端" \
                        "https://github.com/jesseduffield/lazygit" \
                        "/" \
                        "/" \
                        "install_with_package lazygit"
fi

set_software_list   "git-delta" \
                    "delta" \
                    "git客户端" \
                    "https://github.com/dandavison/delta"  \
                    "/" \
                    "/" \
                    "install_with_package git-delta"


if [ $major_version -eq 17 ] ;then
    # https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_0f/openssl-1.1.0f.tar.gz
    # https://github.com/openssl/openssl/releases/download/openssl-3.5.2/openssl-3.5.2.tar.gz
    set_software_list   "openssl" \
                        "openssl" \
                        "基础依赖" \
                        "https://github.com/openssl/openssl"  \
                        "${glabal_github_proxy_url}https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_0f/openssl-1.1.0f.tar.gz" \
                        "/" \
                        "install_software_source_fun1 openssl  cd ${OUTPUT_DIR}/openssl-1.1.0f/openssl-*/ ; ./configure ; make && sudo make install"

    set_software_list   "libevent" \
                        "/usr/local/lib/libevent.a" \
                        "基础依赖" \
                        "https://libevent.org/"  \
                        "${glabal_github_proxy_url}https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz" \
                        "/"  \
                        "install_software_source_fun1 libevent  cd ${OUTPUT_DIR}/libevent-2.1.12-stable/libevent-*/ ; export LDFLAGS="-L/usr/local/opt/openssl/lib" ;  export CPPFLAGS="-I/usr/local/opt/openssl/include"; ./configure --with-openssl --disable-samples --disable-libevent-regress; make && sudo make install"
 

    set_software_list   "ncurses" \
                        "/usr/local/bin/ncursesw6-config" \
                        "基础依赖" \
                        "https://invisible-island.net/ncurses/ncurses.html"  \
                        "https://ftp.gnu.org/gnu/ncurses/ncurses-6.5.tar.gz" \
                        "/"  \
                        "install_software_source_fun1 ncurses  cd ${OUTPUT_DIR}/ncurses-6.5/ncurses-*/ ; ./configure ; make && sudo make install"

    # macOS Serria 下可能缺少依赖：libevent、ncurses
    # brew install libevent ncurses 
    # 或 sudo port install libevent ncurses
    set_software_list   "tmux" \
                        "tmux" \
                        "终端复用器" \
                        "https://github.com/tmux/tmux"  \
                        "${glabal_github_proxy_url}https://github.com/tmux/tmux/releases/download/3.5a/tmux-3.5a.tar.gz" \
                        "/"  \
                        "install_software_source_fun1 tmux  cd ${OUTPUT_DIR}/tmux-3.5a/tmux-*/ ; ./configure --disable-utf8proc ; make && sudo make install"
else 
    set_software_list   "tmux"  \
                        "tmux" \
                        "终端复用器" \
                        "https://github.com/tmux/tmux"  \
                        "/" \
                        "/" \
                        "install_with_package tmux"
fi

if [ $major_version -eq 17 ] ;then 
    set_software_list   "zellij"  \
                        "zellij" \
                        "终端复用器" \
                        "https://github.com/zellij-org/zellij"  \
                        "${glabal_github_proxy_url}https://github.com/zellij-org/zellij/releases/download/v0.43.1/zellij-x86_64-apple-darwin.tar.gz" \
                        "/" \
                        "install_software_fun2 zellij ./zellij  ~/.local/bin"
else
    set_software_list   "zellij"  \
                        "zellij" \
                        "终端复用器" \
                        "https://github.com/zellij-org/zellij"  \
                        "/" \
                        "/" \
                        "install_with_package zellij"
fi

set_software_list   "vim"  \
                    "vim"  \
                    "神之编辑器vim" \
                    "https://www.vim.org/download.php" \
                    "/"  \
                    "/"  \
                    "install_with_package vim"

if [ $major_version -eq 17 ] ;then 
    set_software_list   "neovim" \
                        "nvim" \
                        "编辑器nvim" \
                        "https://neovim.io/" \
                        "${glabal_github_proxy_url}https://github.com/neovim/neovim/releases/download/v0.11.3/nvim-macos-x86_64.tar.gz" \
                        "/"  \
                        "install_software_fun2 nvim ./nvim  ~/.local/bin"
else
    set_software_list   "neovim" \
                        "nvim" \
                        "编辑器nvim" \
                        "https://neovim.io/" \
                        "/" \
                        "/"  \
                        "install_with_package nvim"
fi

set_software_list   "helix"  \
                    "hx" \
                    "后现代编辑器" \
                    "https://helix-editor.cn/"  \
                    "/"  \
                    "/"  \
                    "install_with_package helix"

if [ $major_version -eq 17 ] ;then 
    set_software_list   "fzf" \
                        "fzf" \
                        "模糊搜索" \
                        "https://github.com/junegunn/fzf"  \
                        "${glabal_github_proxy_url}https://github.com/junegunn/fzf/releases/download/v0.65.1/fzf-0.65.1-darwin_amd64.tar.gz" \
                        "/"  \
                        "install_software_fun2 fzf ./fzf  ~/.local/bin"
else
    set_software_list   "fzf"  \
                        "fzf"  \
                        "模糊搜索"  \
                        "https://github.com/junegunn/fzf"  \
                        "/"  \
                        "/"  \
                        "install_with_package fzf"
fi

if [ $major_version -eq 17 ] ;then
    set_software_list   "fd" \
                        "fd"  \
                        "Rust搜索工具"  \
                        "https://github.com/sharkdp/fd" \
                        "${glabal_github_proxy_url}https://github.com/sharkdp/fd/releases/download/v10.2.0/fd-v10.2.0-x86_64-apple-darwin.tar.gz"  \
                        "/"  \
                        "install_software_fun2 fd ./fd ~/.local/bin"
else
    set_software_list   "fd" \
                        "fd"  \
                        "Rust搜索工具"  \
                        "https://github.com/sharkdp/fd" \
                        "/"  \
                        "/"  \
                        "install_with_package fd"
fi

if [ $major_version -eq 17 ] ;then
    set_software_list   "skim" \
                        "sk" \
                        "rust模糊搜索" \
                        "https://github.com/skim-rs/skim" \
                        "${glabal_github_proxy_url}https://github.com/skim-rs/skim/releases/download/v0.20.5/skim-x86_64-apple-darwin.tgz" \
                        "/"  \
                        "install_software_fun2 skim ./sk ~/.local/bin"
else
    set_software_list   "skim" \
                        "sk" \
                        "rust模糊搜索" \
                        "https://github.com/skim-rs/skim" \
                        "/" \
                        "/"  \
                        "install_with_package sk"
fi

set_software_list   "ripgrep" \
                    "rg"  \
                    "搜索"  \
                    "https://github.com/BurntSushi/ripgrep"  \
                    "/" \
                    "/" \
                    "install_with_package ripgrep"

set_software_list   "ack" \
                    "ack" \
                    "搜索" \
                    "/"  \
                    "/" \
                    "/" \
                    "install_with_package ack"

set_software_list   "bat" \
                    "bat" \
                    "具有语法高亮和Git集成的cat类命令"  \
                    "/"  \
                    "/"  \
                    "/"  \
                    "install_with_package bat"

set_software_list   "tree" \
                    "tree" \
                    "树状文件列表"  \
                    "/"   \
                    "/"   \
                    "/"   \
                    "install_with_package tree"

set_software_list   "eza"  \
                    "eza"  \
                    "文件清单美化"  \
                    "/"   \
                    "/"   \
                    "/"   \
                    "install_with_package eza"

set_software_list   "fswatch" \
                    "fswatch"  \
                    "文件变化监测器"  \
                    "/"  \
                    "/"  \
                    "/"  \
                    "install_with_package fswatch"

set_software_list   "terminal-notifier" \
                    "terminal-notifier"  \
                    "命令行发送工具"   \
                    "/" \
                    "/" \
                    "/" \
                    "install_with_package terminal-notifier"

set_software_list   "ranger" \
                    "ranger" \
                    "终端字符文件管理器"  \
                    "/"  \
                    "/"  \
                    "/"  \
                    "install_with_package ranger reattach-to-user-namespace"

if [ $major_version -eq 17 ] ;then
    set_software_list   "yazi"  \
                        "yazi" \
                        "终端字符文件管理器"  \
                        "https://github.com/sxyazi/yazi" \
                        "${glabal_github_proxy_url}https://github.com/sxyazi/yazi/releases/download/v25.5.31/yazi-x86_64-apple-darwin.zip" \
                        "/"  \
                        "install_software_fun2 yazi ./y* ~/.local/bin"
else
    set_software_list   "yazi"  \
                        "yazi" \
                        "终端字符文件管理器"  \
                        "https://github.com/sxyazi/yazi" \
                        "/" \
                        "/" \
                        "install_with_package yazi"
fi

set_software_list   "lf"  \
                    "lf"  \
                    "终端字符文件管理器"   \
                    "/"   \
                    "/"   \
                    "/"   \
                    "install_with_package lf"

if [ $major_version -eq 17 ] ;then 
    set_software_list   "ffmpeg" \
                        "ffmpeg"  \
                        "多媒体框架 https://ffmpeg.org/" \
                        "https://github.com/FFmpeg/FFmpeg" \
                        "https://evermeet.cx/ffmpeg/ffmpeg-120751-g1d06e8ddcd.zip" \
                        "/"   \
                        "install_software_fun2 ffmpeg ./* ~/.local/bin"
else
    set_software_list   "ffmpeg" \
                        "ffmpeg"  \
                        "多媒体框架" \
                        "https://github.com/FFmpeg/FFmpeg"  \
                        "/"   \
                        "/"   \
                        "install_with_package ffmpeg"
fi

if [ $major_version -eq 17 ] ;then 
    # macOS High Sierra 10.13 ,安装了xcode command line tools 但是 swift版本是4.2
    # N_m3u8DL-RE最新版本可能需要更高版本的Swift。
    # 查看版本命令 swift --version 
    set_software_list   "N_m3u8DL-RE" \
                        "N_m3u8DL-RE" \
                        "跨平台的DASH/HLS/MSS下载工具" \
                        "https://github.com/nilaoda/N_m3u8DL-RE"  \
                        "${glabal_github_proxy_url}https://github.com/nilaoda/N_m3u8DL-RE/releases/download/v0.1.3-beta/N_m3u8DL-RE_Beta_osx-x64_20221202.tar.gz"  \
                        "/"   \
                        "install_software_fun2 N_m3u8DL-RE ./N_m3u8DL-RE ~/.local/bin"
else
    # 需要更高版本的Swift版本是5.2
    set_software_list   "N_m3u8DL-RE" \
                        "N_m3u8DL-RE" \
                        "跨平台的DASH/HLS/MSS下载工具" \
                        "https://github.com/nilaoda/N_m3u8DL-RE"  \
                        "${glabal_github_proxy_url}https://github.com/nilaoda/N_m3u8DL-RE/releases/download/v0.3.0-beta/N_m3u8DL-RE_v0.3.0-beta_osx-x64_20241203.tar.gz"  \
                        "/"   \
                        "install_software_fun2 N_m3u8DL-RE ./N_m3u8DL-RE ~/.local/bin"
fi

set_software_list  "yt-dlp" \
                   "yt-dlp_macos" \
                   "跨平台的DASH/HLS/MSS下载工具" \
                   "https://github.com/yt-dlp/yt-dlp"  \
                   "${glabal_github_proxy_url}https://github.com/yt-dlp/yt-dlp/releases/download/2025.08.20/yt-dlp_macos.zip"  \
                   "/"   \
                   "install_software_fun2 yt-dlp ./yt-dlp_macos ~/.local/bin"

set_software_list   "BBDown" \
                    "BBDown" \
                    "B站下载工具"  \
                    "https://github.com/nilaoda/BBDown/"  \
                    "${glabal_github_proxy_url}https://github.com/nilaoda/BBDown/releases/download/1.6.3/BBDown_1.6.3_20240814_osx-x64.zip" \
                    "/"   \
                    "install_software_fun2 BBDown ./BBDown ~/.local/bin"

set_software_list  "BBDown.config" \
                   "~/.local/bin/BBDown.config" \
                   "B站下载工具配置" \
                   "/"  \
                   "/"  \
                   "/"   \
                   "if [[ ! -f ~/.local/bin/BBDown.config ]]; then
                      if [[ ! -d ~/.local/bin ]]; then  
                        mkdir ~/.local/bin;
                      fi ;
                      echo '--work-dir $HOME/Downloads --skip-ai False' > '$HOME/.local/bin/BBDown.config' ;
                    fi"

set_software_list  "nap" \
                   "nap" \
                   "终端代码片段管理器" \
                   "https://github.com/maaslalani/nap"  \
                   "${glabal_github_proxy_url}https://github.com/maaslalani/nap/releases/download/v0.1.1/nap_0.1.1_darwin_amd64.tar.gz"  \
                   "/"   \
                   "install_software_fun2 nap ./nap ~/.local/bin"


set_software_list   "lua"   \
                    "lua"  \
                    "编程环境lua"  \
                    "/"  \
                    "/"  \
                    "/"  \
                    "install_with_package lua"

set_software_list   "nvm"   \
                    "nvm"   \
                    "编程环境：nodejs版本管理"  \
                    "/"   \
                    "/"   \
                    "/"   \
                    "install_with_package nvm ;mkdir ~/.nvm"

set_software_list   "pnpm"  \
                    "pnpm"  \
                    "编程环境：node包管理"  \
                    "/"  \
                    "/"  \
                    "/"  \
                    "install_with_package pnpm"

if [ $major_version -eq 17 ] ;then 
    set_software_list   "pyenv" \
                        "pyenv" \
                        "编程环境：python版本管理" \
                        "https://github.com/pyenv/pyenv"  \
                        "/"  \
                        "/"  \
                        "git clone --depth  1 ${glabal_github_proxy_url}https://github.com/pyenv/pyenv.git ~/.pyenv ;"
    # echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc;
    # echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc;
    # echo 'export PATH="$PYENV_ROOT/shims:$PATH"' >> ~/.bashrc;
    # echo 'eval "$(pyenv init -)"' >> ~/.bashrc;
    # exec $SHELL -l;

    # echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc;
    # echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc;
    # echo 'export PATH="$PYENV_ROOT/shims:$PATH"' >> ~/.zshrc;
    # echo 'eval "$(pyenv init -)"' >> ~/.zshrc;
    # exec $SHELL -l;

    # 依赖：
    # pyenv install 3.8.9 自动下载安装时，需要依赖， 运行时会自动安装 （手动提前安装 brew install openssl readline sqlite3 xz zlib ）
    # 离线安装 下载的Python-3.8.9.tar.xz拷贝到目标Mac的~/.pyenv/cache 目录下（如果没有cache目录，则创建它）
else
    set_software_list   "pyenv" \
                        "pyenv" \
                        "编程环境：python版本管理"  \
                        "/"  \
                        "/"  \
                        "/"  \
                        "install_with_package pyenv pyenv-virtualenv"
fi

# pythonProxyUrl="https://www.python.org/ftp/python" # 官方
# pythonProxyUrl="https://mirrors.huaweicloud.com/python" # 华为云镜像地址
pythonProxyUrl="https://registry.npmmirror.com/-/binary/python"
pythonVersion="3.8.9"
downloadUrl="${pythonProxyUrl}/${pythonVersion}/Python-${pythonVersion}.tar.xz"
set_software_list   "pyenv-python-${pythonVersion}" \
                    "$HOME/.pyenv/cache/Python-${pythonVersion}.tar.xz" \
                    "编程环境：python（${pythonVersion}）" \
                    "${pythonProxyUrl}"  \
                    "${downloadUrl}"  \
                    "/" \
                    "install_software_fun1 pyenv-python-${pythonVersion} mkdir -p $HOME/.pyenv/cache ; cp ${OUTPUT_DIR}/Python-${pythonVersion}.tar.xz ${HOME}/.pyenv/cache/;"
pythonVersion="3.10.9"
downloadUrl="${pythonProxyUrl}/${pythonVersion}/Python-${pythonVersion}.tar.xz"
set_software_list   "pyenv-python-${pythonVersion}" \
                    "$HOME/.pyenv/cache/Python-${pythonVersion}.tar.xz" \
                    "编程环境：python（${pythonVersion}）" \
                    "${pythonProxyUrl}"  \
                    "${downloadUrl}"  \
                    "/" \
                    "install_software_fun1 pyenv-python-${pythonVersion}  mkdir -p $HOME/.pyenv/cache ; cp ${OUTPUT_DIR}/Python-${pythonVersion}.tar.xz ${HOME}/.pyenv/cache/;"
                    # "curl  ${downloadUrl} -o ${OUTPUT_DIR}/Python-${pythonVersion}.tar.xz &&
                    #  mkdir -p $HOME/.pyenv/cache &&
                    #  mv ${OUTPUT_DIR}/Python-${pythonVersion}.tar.xz ${HOME}/.pyenv/cache/"

set_software_list   "perl" \
                    "perl" \
                    "编程环境"  \
                    "/" \
                    "/" \
                    "/" \
                    "install_with_package perl"

set_software_list   "hashcat"  \
                    "hashcat" \
                    "破解工具" \
                    "/"   \
                    "/"   \
                    "/"   \
                    "install_with_package hashcat"

set_software_list   "john-jumbo" \
                    "john"  \
                    "破解工具"  \
                    "/"   \
                    "/"   \
                    "/"   \
                    "install_with_package john-jumbo"

set_software_list   "cpanm"  \
                    "cpanm" \
                    "Perl模块管理"  \
                    "/"   \
                    "/"   \
                    "/"   \
                    "install_with_package cpanm"

# GUI
if [ "$major_version" -le 17 ] ;then kitty_version="0.17.4"; else kitty_version="0.42.2";fi;
set_software_list   "kitty" \
                    "/Applications/kitty.app"  \
                    "GPU终端(${kitty_version})"  \
                    "https://github.com/kovidgoyal/kitty" \
                    "${glabal_github_proxy_url}https://github.com/kovidgoyal/kitty/releases/download/v${kitty_version}/kitty-${kitty_version}.dmg" \
                    "/"   \
                    "install_software_fun1 kitty"
# [kitty -- 一个被严重忽视的生产力利器 | /dev/ttyS3 Blog](https://ttys3.dev/blog/kitty)

if [ "$major_version" -le 17 ] ;then wezterm_version="20230712-072601-f4abf8fd"; else wezterm_version="20240203-110809-5046fc22";fi;
set_software_list   "wezterm" \
                    "/Applications/WezTerm.app"  \
                    "GPU终端(${wezterm_version})"  \
                    "https://github.com/wezterm/wezterm" \
                    "${glabal_github_proxy_url}https://github.com/wezterm/wezterm/releases/download/${wezterm_version}/WezTerm-macos-${wezterm_version}.zip" \
                    "/"   \
                    "install_software_fun1 wezterm"

if [ $major_version -ge 18 ] ;then # 高于 macOS high Sierra
    if [ "$metal_support_version" -le 1 ] ;then  localsend_version="1.7.0"; else localsend_version="1.17.0";fi;
    set_software_list  "localsend"  \
                       "/Applications/LocalSend.app" \
                       "局域网传输工具v($localsend_version)" \
                       "https://github.com/localsend/localsend" \
                       "${glabal_github_proxy_url}https://github.com/localsend/localsend/releases/download/v${localsend_version}/LocalSend-${localsend_version}.dmg" \
                       "/"   \
                       "install_software_dmg localsend"
fi


if [ "$major_version" -le 17 ] ;then 
    set_software_list  "LANDrop"  \
                        "/Applications/LANDrop.app" \
                        "局域网传输工具" \
                        "https://github.com/LANDrop/LANDrop" \
                        "${glabal_github_proxy_url}https://github.com/LANDrop/LANDrop/releases/download/v0.4.0/LANDrop-0.4.0-macos.dmg" \
                        "/"   \
                        "install_software_dmg LANDrop"
elif  [ "$major_version" -ge 18 ] ;then 
    set_software_list   "LANDrop"  \
                        "/Applications/LANDrop.app" \
                        "局域网传输工具(0.4.0)" \
                        "https://landrop.app/" \
                        "https://releases.landrop.app/landrop-v2-electron/LANDrop-2.7.2-macos-universal.dmg" \
                        "/"   \
                        "install_software_dmg LANDrop"
# else
#     set_software_list   "LANDrop"  \
#                         "/Applications/LANDrop.app" \
#                         "局域网传输工具(0.4.0)" \
#                         "https://github.com/LANDrop/LANDrop" \
#                         "${glabal_github_proxy_url}https://github.com/LANDrop/LANDrop/releases/download/v0.4.0/LANDrop-0.4.0-macos.dmg" \
#                         "/"   \
#                         "install_software_dmg LANDrop"
fi

set_software_list   "NeatDownloadManager"  \
                    "/Applications/NeatDownloadManager.app"  \
                    "下载工具https://neatdownload.com/"   \
                    "https://github.com/Neatdownloadmanager/Neat-Download-Manager"   \
                    "https://neatdownloadmanager.com/file/NeatDMInstaller.dmg"   \
                    "/" \
                    "install_software_dmg NeatDownloadManager"

set_software_list  "freefilesync"  \
                    "/Applications/FreeFileSync.app"  \
                    "文件同步工具"   \
                    "https://freefilesync.org/"   \
                    "https://freefilesync.org/download/FreeFileSync_14.4_macOS.zip"   \
                    "/" \
                    "install_software_fun1 freefilesync"

if [ "$major_version" -le 17 ] ;then vscode_version="1.82.3"; else vscode_version="1.103.2";fi;
set_software_list   "VSCode" \
                    "/Applications/Visual Studio Code.app" \
                    "文本编辑器(${vscode_version})"  \
                    "https://code.visualstudio.com/"  \
                    "https://update.code.visualstudio.com/${vscode_version}/darwin-universal/stable"  \
                    "/" \
                    "open_url_with_brower  VSCode"

set_software_list   "sublime_text4"  \
                    "/Applications/Sublime Text.app"  \
                    "文本编辑器"   \
                    "https://www.sublimetext.com/download"  \
                    "https://download.sublimetext.com/sublime_text_build_4200_mac.zip"  \
                    "/" \
                    "install_software_fun1 sublime_text4"

set_software_list   "sublimemerge"  \
                    "/Applications/Sublime Merge.app"  \
                    "git客户端"   \
                    "https://www.sublimemerge.com/"   \
                    "https://download.sublimetext.com/sublime_merge_build_2102_mac.zip"   \
                    "/" \
                    "install_software_fun1 sublimemerge" 

if [ $major_version -eq 17 ] ;then obsidian_version="1.2.8"; else  obsidian_version="1.9.10"; fi;
set_software_list   "obsidian" \
                    "/Applications/Obsidian.app"  \
                    "笔记编辑器(${obsidian_version})"  \
                    "https://obsidian.md/download" \
                    "${glabal_github_proxy_url}https://github.com/obsidianmd/obsidian-releases/releases/download/v${obsidian_version}/Obsidian-${obsidian_version}.dmg"  \
                    "/" \
                    "install_software_dmg obsidian"


set_software_list   "lemon"  \
                    "/Applications/Tencent Lemon.app"  \
                    "腾讯柠檬清理"   \
                    "https://lemon.qq.com/"   \
                    "https://pm.myapp.com/invc/xfspeed/qqpcmgr/module_update/BC4FB28CB59D1A9FEE2D9EDB167B25A9/Lemon5.1.16.dmg"   \
                    "/" \
                    "install_software_dmg lemon"

set_software_list   "iina"  \
                    "/Applications/IINA.app"  \
                    "视频播放器https://iina.io/"  \
                    "https://github.com/iina/iina"  \
                    "${glabal_github_proxy_url}https://github.com/iina/iina/releases/download/v1.3.5/IINA.v1.3.5.dmg"  \
                    "/" \
                    "install_software_dmg iina"

if [ $major_version -eq 17 ] ;then 
    set_software_list   "wechat" \
                        "/Applications/WeChat.app"  \
                        "微信(3.8.10)"   \
                        "https://weixin.qq.com/" \
                        "https://dldir1v6.qq.com/weixin/mac/WeChatMac_10_15.dmg"  \
                        "/" \
                        "install_software_dmg wechat"
    # [macOS 微信(3.8.10 ) ](https://dldir1v6.qq.com/weixin/mac/WeChatMac_10_15.dmg) (macOS High Sierra 10.13.5 能安装能登陆)
    # [macOS 微信(3.5.5) ](https://github.com/zsbai/wechat-versions/releases/download/v3.5.5/WeChatMac-3.5.5.dmg)(macOS High Sierra 10.13.5 能安装,不能能登陆-提示版本过低不让登陆自动退出)
    # [macOS 微信(3.1.1) ](https://dldir1.qq.com/weixin/mac/wechat-beta-19025-1625715704.dmg?t1625715704)
    # [macOS 微信(3.0.0.17689 Beta 1) ](https://dldir1.qq.com/weixin/mac/wechat-beta-17689-1615445873.dmg)
    # [macOS 微信内测版本(2.3.0) ](https://dldir1.qq.com/weixin/mac/wechat-9252-1501143620.dmg)(macOS High Sierra 10.13.5 能安装,不能能登陆-提示版本过低不让登陆自动退出)
else
    set_software_list   "wechat" \
                        "/Applications/WeChat.app"  \
                        "微信"   \
                        "https://weixin.qq.com/" \
                        "https://dldir1v6.qq.com/weixin/Universal/Mac/WeChatMac.dmg"  \
                        "/" \
                        "install_software_dmg wechat"
fi

if [ $major_version -eq 17 ] ;then 
    set_software_list   "qq" \
                        "/Applications/QQ-NT.app" \
                        "QQ(6.7.6)" \
                        "https://im.qq.com/" \
                        "https://dldir1.qq.com/qqfile/qq/QQNT/QQ_6.8.6.4481_exp.dmg" \
                        "/" \
                        "install_software_dmg qq"
    # https://dldir1.qq.com/qqfile/QQforMac/QQ_6.7.6.dmg         （10.13能安装，但是登陆提示版本太低退出）
    # https://dldir1.qq.com/qqfile/qq/QQNT/QQ_6.8.6.4481_exp.dmg （10.13能安装，但是登陆提示版本太低退出）
    # https://dldir1.qq.com/qqfile/qq/QQNT/3b118efd/QQ_v6.9.2-7809.dmg （10.13无法安装）
    # https://dldir1.qq.com/qqfile/qq/QQNT/27abc38b/QQ_v6.9.10-9733.dmg （10.13无法安装）
else
    set_software_list   "qq" \
                        "/Applications/QQ.app" \
                        "QQ(6.9.77)" \
                        "https://im.qq.com/" \
                        "https://dldir1v6.qq.com/qqfile/qq/QQNT/Mac/QQ_6.9.77_250724_01.dmg" \
                        "/" \
                        "install_software_dmg qq"
fi
# [QQ for Mac 历史版本](https://mac.filehorse.com/download-qq/old-versions/#google_vignette)

set_software_list   "telegram"  \
                    "/Applications/Telegram.app"  \
                    "飞机Telegram https://desktop.telegram.org/" \
                    "https://github.com/telegramdesktop/tdesktop"  \
                    "${glabal_github_proxy_url}https://github.com/telegramdesktop/tdesktop/releases/download/v6.0.2/tsetup.6.0.2.dmg"  \
                    "/" \
                    "install_software_dmg telegram"

set_software_list   "wps"  \
                    "/Applications/wpsoffice.app"  \
                    "WPS文档"   \
                    "https://www.wps.cn/"   \
                    "https://package.mac.wpscdn.cn/mac_wps_pkg/wps_installer/WPS_Office_Installer.zip"   \
                    "/" \
                    "install_software_fun1 wps"

set_software_list   "chrome"  \
                    "/Applications/Google Chrome.app"  \
                    "谷歌浏览器"   \
                    "https://www.google.cn/intl/en_uk/chrome/"  \
                    "https://dl.google.com/chrome/mac/universal/stable/GGRO/googlechrome.dmg"   \
                    "/" \
                    "install_software_fun1 chrome"

if [ $major_version -eq 17 ] ;then 
    set_software_list   "NeteaseCloudMusic"  \
                        "/Applications/NeteaseMusic.app"  \
                        "网易云音乐（2.3.21_1077）"   \
                        "https://music.163.com/"   \
                        "https://d1.music.126.net/dmusic/NeteaseMusic_2.3.21_1077_web.dmg"   \
                        "/" \
                        "install_software_fun1 NeteaseCloudMusic"
else
    set_software_list   "NeteaseCloudMusic"  \
                        "/Applications/NeteaseMusic.app"  \
                        "网易云音乐（3.0.18）"   \
                        "https://music.163.com/"   \
                        "https://d1.music.126.net/dmusic/NeteaseCloudMusic_Music_official_3.0.18.2885_x86_64.dmg" \
                        "/" \
                        "install_software_fun1 NeteaseCloudMusic"
fi

set_software_list   "NutstoreOSXInstaller"  \
                    "/Applications/Nutstore.app"  \
                    "坚果云"   \
                    "https://www.jianguoyun.com/s/downloads"  \
                    "https://pkg-cdn.jianguoyun.com/static/exe/installer/NutstoreOSXInstaller.dmg"  \
                    "/" \
                    "install_software_fun1 NutstoreOSXInstaller"

if [ $major_version -eq 17 ] ;then seafile_client_version="7.0.2" else seafile_client_version="9.0.14" fi;
    set_software_list   "seafile" \
                        "/Applications/Seafile Client.app"  \
                        "seafile云盘(${seafile_client_version})"  \
                        "https://www.seafile.com/" \
                        "https://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-client-${seafile_client_version}.dmg" \
                        "/" \
                        "install_software_dmg seafile"    
fi       
# 归档的seafile下载页面 https://web.archive.org/web/20190921184125/https://www.seafile.com/en/download/
# https://web.archive.org/web/20190921184125/https://download.seadrive.org/seafile-client-7.0.2.dmg

set_software_list   "Android File Transfer"  \
                    "/Applications/Android File Transfer.app"  \
                    "Android文件传输"  \
                    "https://formulae.brew.sh/cask/android-file-transfer"   \
                    "https://dl.google.com/dl/androidjumper/mtp/5071136/androidfiletr"   \
                    "30c5c356e55f992ab0e8198bedcce93f"   \
                    "brew install --cask android-file-transfer"

# brew fetch --cask android-file-transfer
# 下载文件在 /Users/用户名/Library/Caches/Homebrew/downloads/
# 如何在 Mac 上检查文件的 md5 哈希 命令 ： md5  <文件路径>
# 如何在 Mac 上检查文件的 sha256 哈希 命令： shasum  <文件路径>


set_software_list   "AndroidFileTransferForLinux"  \
                    "/Applications/Android File Transfer for Linux.app"  \
                    "Android文件传输"  \
                    "https://github.com/whoozle/android-file-transfer-linux"   \
                    "${glabal_github_proxy_url}https://github.com/whoozle/android-file-transfer-linux/releases/download/v4.5/AndroidFileTransferForLinux.dmg"   \
                    "/"   \
                    "install_software_fun1 AndroidFileTransferForLinux"

set_software_list   "openmtp"  \
                    "/Applications/OpenMTP.app"  \
                    "Android文件传输"  \
                    "https://github.com/ganeshrvel/openmtp" \
                    "${glabal_github_proxy_url}https://github.com/ganeshrvel/openmtp/releases/download/v3.2.25/openmtp-3.2.25-mac-x64.dmg"   \
                    "/"   \
                    "install_software_dmg openmtp"

set_software_list   "Moonlight"  \
                    "/Applications/Moonlight.app"  \
                    "串流客户端"  \
                    "https://moonlight-stream.org/" \
                    "${glabal_github_proxy_url}https://github.com/moonlight-stream/moonlight-qt/releases/download/v6.1.0/Moonlight-6.1.0.dmg"   \
                    "/"   \
                    "install_software_dmg Moonlight"





set_software_list  "koodo"  \
                    "/Applications/Koodo Reader.app"  \
                    "电子书阅读器"  \
                    "https://github.com/koodo-reader/koodo-reader" \
                    "${glabal_github_proxy_url}https://github.com/koodo-reader/koodo-reader/releases/download/v2.0.7/Koodo-Reader-2.0.7-x64.dmg"   \
                    "/" \
                    "install_software_dmg koodo"

set_software_list  "readest"  \
                    "/Applications/Readest.app"  \
                    "电子书阅读器"  \
                    "https://github.com/readest/readest" \
                    "${glabal_github_proxy_url}https://github.com/readest/readest/releases/download/v0.9.67/Readest_0.9.67_universal.dmg"   \
                    "/"   \
                    "install_software_dmg readest"

set_software_list  "sniffnet"  \
                    "/Applications/Sniffnet.app"  \
                    "流量监控"  \
                    "https://github.com/GyulyVGC/sniffnet" \
                    "${glabal_github_proxy_url}https://github.com/GyulyVGC/sniffnet/releases/download/v1.4.0/Sniffnet_macOS_Intel.dmg"   \
                    "/"   \
                    "install_software_dmg sniffnet"

set_software_list  "obs"  \
                    "/Applications/ObsStudio.app"  \
                    "obs录屏"  \
                    "https://obsproject.com/download" \
                    "https://cdn-fastly.obsproject.com/downloads/obs-studio-31.1.1-macos-intel.dmg"   \
                    "/"   \
                    "install_software_dmg obs"

if [ $major_version -eq 17 ] ;then pot_version="0.5.0" else pot_version="3.0.7" fi;
set_software_list   "pot" \
                    "/Applications/pot.app"  \
                    "划词翻译和OCR软件(${pot_version})"  \
                    "https://github.com/pot-app/pot-desktop"  \
                    "${glabal_github_proxy_url}https://github.com/pot-app/pot-desktop/releases/download/${pot_version}/pot_${pot_version}_x64.dmg" \
                    "/"   \
                    "install_software_dmg pot"


set_software_list   "motrix"  \
                    "/Applications/motrix.app"  \
                    "功能齐全的下载管理器" \
                    "https://motrix.app/" \
                    "https://dl.motrix.app/release/Motrix-1.8.19.dmg"   \
                    "/"   \
                    "install_software_dmg motrix"

if [ $major_version -ge 18 ] ;then 
    mihomo_party_version="1.8.4";
# else
    set_software_list   "mihomo_party"  \
                        "/Applications/mihomo_party.app"  \
                        "功能齐全的下载管理器" \
                        "https://github.com/mihomo-party-org/mihomo-party" \
                        "https://github.com/mihomo-party-org/mihomo-party/releases/download/v${mihomo_party_version}/mihomo-party-macos-${mihomo_party_version}-x64.dmg"   \
                        "/"   \
                        "install_software_dmg mihomo_party"
fi

if [ $major_version -eq 17 ] ;then 
    set_software_list   "thunder"  \
                        "/Applications/Thunder.app" \
                        "迅雷（4.2.1）" \
                        "https://mac.xunlei.com/" \
                        "https://down.sandai.net/mac/thunder_4.2.1.65254.dmg"  \
                        "/"   \
                        "install_software_dmg thunder"
else
    set_software_list   "thunder"  \
                        "/Applications//Applications/Thunder.app" \
                        "迅雷（5.80.1）" \
                        "https://mac.xunlei.com/" \
                        "https://down.sandai.net/mac/thunder_5.80.1.66541.dmg"  \
                        "/"   \
                        "install_software_dmg thunder"
fi

if [ $major_version -eq 17 ] ;then 
    # https://github.com/YACReader/yacreader/releases/download/9.13.0/YACReader-9.13.0.2307095.MacOSX-Intel.Qt5.dmg (macOS High Sierra 10.13.6 能安装但是打开崩溃)
    # https://github.com/YACReader/yacreader/releases/download/9.12.0/YACReader-9.12.0.2304234.MacOSX-Intel.Qt5.dmg (macOS High Sierra 10.13.6 能安装但是打开崩溃)
    # https://github.com/YACReader/yacreader/releases/download/9.11.0/YACReader-9.11.0.2301073.MacOSX-Intel.Qt5.dmg  (macOS High Sierra 10.13.6 打开要创建库时崩溃)
    # https://github.com/YACReader/yacreader/releases/download/9.10.0/YACReader-9.10.0.2210304.MacOSX-Intel.Qt5.dmg  (macOS High Sierra 10.13.6 打开要创建库时崩溃)
    # https://github.com/YACReader/yacreader/releases/download/9.9.1/YACReader-9.9.1.2209046.MacOSX-Intel.dmg (macOS High Sierra 10.13.6 打开要创建库时崩溃)
    set_software_list   "YACReader"  \
                        "/Applications/YACReader.app" \
                        "漫画管理" \
                        "https://www.yacreader.com/downloads" \
                        "${glabal_github_proxy_url}https://github.com/YACReader/yacreader/releases/download/9.8.1/YACReader-9.8.1.2106024.MacOSX-Intel.dmg" \
                        "/"   \
                        "install_software_dmg YACReader"

    set_software_list   "YACReaderLibrary"  \
                        "/Applications/YACReaderLibrary.app" \
                        "漫画管理" \
                        "https://www.yacreader.com/downloads" \
                        "${glabal_github_proxy_url}https://github.com/YACReader/yacreader/releases/download/9.8.1/YACReader-9.8.1.2106024.MacOSX-Intel.dmg" \
                        "/"   \
                        "install_software_dmg YACReaderLibrary"
else
    set_software_list   "YACReader"  \
                        "/Applications/YACReader.app" \
                        "漫画管理" \
                        "https://www.yacreader.com/downloads" \
                        "${glabal_github_proxy_url}https://github.com/YACReader/yacreader/releases/download/9.15.0/YACReader-9.15.0.2501014.MacOSX-Intel.Qt5.dmg" \
                        "/"   \
                        "install_software_dmg YACReader"

    set_software_list   "YACReaderLibrary"  \
                        "/Applications/YACReaderLibrary.app" \
                        "漫画管理" \
                        "https://www.yacreader.com/downloads" \
                        "${glabal_github_proxy_url}https://github.com/YACReader/yacreader/releases/download/9.15.0/YACReader-9.15.0.2501014.MacOSX-Intel.Qt5.dmg" \
                        "/"   \
                        "install_software_dmg YACReaderLibrary"
fi

if [ $major_version -eq 17 ] ;then 
    # https://github.com/BeyondDimension/SteamTools/releases/download/2.4.9/Steam++_macos_x64_v2.4.9.dmg
    set_software_list   "SteamTools"  \
                        "/Applications/Steam++.app" \
                        "「原名 Steam++」Watt Toolkit" \
                        "https://steampp.net/" \
                        "${glabal_github_proxy_url}https://github.com/BeyondDimension/SteamTools/releases/download/2.4.9/Steam++_macos_x64_v2.4.9.dmg" \
                        "/"   \
                        "install_software_dmg SteamTools"
else
    set_software_list   "SteamTools"  \
                        "/Applications/SteamTools.app" \
                        "「原名 Steam++」Watt Toolkit" \
                        "https://steampp.net/" \
                        "${glabal_github_proxy_url}https://github.com/BeyondDimension/SteamTools/releases/download/3.0.0-rc.16/Steam++_v3.0.0-rc.16_macos.dmg" \
                        "/"   \
                        "install_software_dmg SteamTools"
fi
set_software_list   "doxx"  \
                    "doxx" \
                    "终端word查看" \
                    "https://github.com/bgreenwell/doxx" \
                    "${glabal_github_proxy_url}https://github.com/bgreenwell/doxx/releases/download/v0.1.1/doxx-macos-x86_64.tar.gz" \
                    "/"   \
                    "install_software_fun2 doxx ./doxx ~/.local/bin"

set_software_list   "nextTrace"  \
                    "nexttrace_darwin_amd64" \
                    "可视化路线跟踪CLI工具" \
                    "https://github.com/nxtrace/Ntrace-core" \
                    "${glabal_github_proxy_url}https://github.com/nxtrace/NTrace-core/releases/download/v1.4.2/nexttrace_darwin_amd64" \
                    "/"   \
                    "install_software_source_fun1  nextTrace  cp ${OUTPUT_DIR}/nexttrace_darwin_amd64 ~/.local/bin"

set_software_list   "starship"  \
                    "starship" \
                    "适用于任何shell的最小、超快和无限可定制的提示！" \
                    "https://github.com/starship/starship" \
                    "${glabal_github_proxy_url}https://github.com/starship/starship/releases/download/v1.23.0/starship-x86_64-apple-darwin.tar.gz" \
                    "/"   \
                    "install_software_fun2  starship ./starship ~/.local/bin"


# https://github.com/nxtrace/Ntrace-core
# https://github.com/panphora/overtype

if [ $major_version -ge 18  ] ;then 
    set_software_list   "eul"  \
                        "/Applications/eul.app" \
                        "用SwiftUI编写的macOS状态监控应用程序(${eul_version})" \
                        "https://github.com/gao-sun/eul" \
                        "${glabal_github_proxy_url}https://github.com/gao-sun/eul/releases/download/v${eul_version}/eul.app.zip" \
                        "/"   \
                        "install_software_fun1  eul"
fi

if [ $major_version -eq 17 ] ;then stats_version="1.6.5"; else stats_version="2.11.51";fi;
set_software_list   "stats"  \
                    "/Applications/Stats.app" \
                    "macOS状态监控应用程序(${stats_version})" \
                    "https://github.com/exelban/stats" \
                    "${glabal_github_proxy_url}https://github.com/exelban/stats/releases/download/v${stats_version}/Stats.dmg" \
                    "/"   \
                    "install_software_dmg  stats"

if [ $major_version -ge 18  ] ;then 
    set_software_list   "latest"  \
                        "/Applications/Latest.app" \
                        "应用程序的最新更新" \
                        "https://mangerlahn.github.io/Latest/" \
                        "${glabal_github_proxy_url}https://github.com/mangerlahn/Latest/releases/download/0.11/Latest.dmg" \
                        "/"   \
                        "install_software_dmg  latest"
fi

if [ $major_version -ge 18  ] ;then 
    set_software_list   "raycast"  \
                        "/Applications/Raycast.app" \
                        "不止是启动器" \
                        "https://www.raycast.com/raycast/github" \
                        "${glabal_github_proxy_url}https://raycast-releases.9a8adc978cc22e82f2df4dd5f45c4ef2.r2.cloudflarestorage.com/Raycast_v1.102.5_330e31397d09dd2b1909a9ba82a20b573f0097de_universal.dmg?response-content-disposition=attachment%3B%20filename%3D%22Raycast.dmg%22&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=b3c053179dd07241f8271dbe9002b57e%2F20250826%2Fauto%2Fs3%2Faws4_request&X-Amz-Date=20250826T010325Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=a613526a42bbc653982fa27aab0c082e88c6d3456aa0399a65e00e12b5efc117" \
                        "/"   \
                        "install_software_dmg  raycast"
fi



set_software_list   "rubick"  \
                    "/Applications/rubick.app" \
                    "桌面端效率工具箱" \
                    "https://github.com/rubickCenter/rubick" \
                    "${glabal_github_proxy_url}https://github.com/rubickCenter/rubick/releases/download/v4.3.5/rubick-4.3.5-x64.dmg" \
                    "/"   \
                    "install_software_dmg  rubick"


if [ $major_version -eq 17 ] ;then utools_version="4.0.0"; else utools_version="7.2.1";fi;
    set_software_list   "u-tools"  \
                        "/Applications/uTools.app" \
                        "桌面端效率工具箱" \
                        "https://www.u-tools.cn/download/" \
                        "${glabal_github_proxy_url}https://open.u-tools.cn/download/uTools-${utools_version}.dmg" \
                        "/"   \
                        "install_software_dmg  u-tools"
fi

set_software_list   "keka"  \
                    "/Applications/keka.app" \
                    "macOS和iOS文件归档程序" \
                    "https://github.com/aonez/Keka" \
                    "${glabal_github_proxy_url}https://github.com/aonez/Keka/releases/download/v1.5.2/Keka-1.5.2.dmg" \
                    "/"   \
                    "install_software_dmg  keka"

if [ $major_version -eq 17 ] ;then maccy_version="0.16.0"; else maccy_version="2.4.1";fi;
set_software_list   "maccy"  \
                    "/Applications/maccy.app/" \
                    "轻量级剪贴板管理器(v${maccy_version})" \
                    "https://github.com/p0deje/Maccy" \
                    "${glabal_github_proxy_url}https://github.com/p0deje/Maccy/releases/download/${maccy_version}/Maccy.app.zip" \
                    "/"   \
                    "install_software_fun1  maccy"


if [ $major_version -ge 18  ] ;then 
    set_software_list   "QuickRecorder"  \
                        "/Applications/QuickRecorder.app/" \
                        "基于 ScreenCapture Kit 的轻量化多功能 macOS 录屏工具" \
                        "https://github.com/lihaoyun6/QuickRecorder" \
                        "${glabal_github_proxy_url}https://github.com/lihaoyun6/QuickRecorder/releases/download/1.6.9/QuickRecorder_v1.6.9.dmg" \
                        "/"   \
                        "install_software_dmg  QuickRecorder"
fi

set_software_list   "XLD"  \
                    "/Applications/PDFgear.app/" \
                    "无损音频解码／转码／播放软件" \
                    "https://tmkk.undo.jp/xld/index_e.html" \
                    "https://zenlayer.dl.sourceforge.net/project/xld/xld-20250302.dmg?viasf=1" \
                    "/"   \
                    "install_software_dmg  PDFgear"

set_software_list   "PDFgear"  \
                    "/Applications/PDFgear.app/" \
                    "PDF编辑" \
                    "hhttps://www.pdfgear.com/zh/" \
                    "https://apps.apple.com/app/apple-store/id6469021132?os=mac&lang=zh&cid=frm_stp_dl" \
                    "/"   \
                    "open_url_with_brower  PDFgear"
# brew fetch --cask PDFgear

set_software_list   "amorphousdiskmark"  \
                    "/Applications/AmorphousDiskMark.app" \
                    "硬盘测速工具" \
                    "hhttps://www.pdfgear.com/zh/" \
                    "https://katsurashareware.com/dl/AmorphousDiskMark.zip" \
                    "/"   \
                    "install_software_fun1  amorphousdiskmark"

if [ $major_version -eq 17 ] ;then macfuse_version="4.10.2"; else macfuse_version="5.0.5";fi;
set_software_list   "macfuse"  \
                    "/Library/Filesystems/macfuse.fs/Contents/Resources/mount_macfuse" \
                    "NTFS硬盘读写依赖" \
                    "https://macfuse.github.io/" \
                    "https://github.com/macfuse/macfuse/releases/download/macfuse-${macfuse_version}/macfuse-${macfuse_version}.dmg" \
                    "/"   \
                    "install_software_fun1  macfuse"

set_software_list   "ntfs-3g"  \
                    "ntfs-3g" \
                    "NTFS硬盘读写命令工具" \
                    "/" \
                    "/" \
                    "/"   \
                    "install_with_package  ntfs-3g"

# 手动挂载硬盘：
# 首先，断开硬盘再重新连接。在终端中输入 mount 命令找到你的硬盘，记下它的设备标识符（如 /dev/disk2s1）和当前挂载点（如 /Volumes/MyPassport）。
# 先卸载它：
# sudo umount /Volumes/MyPassport
# 创建一个新的挂载点目录（如果不存在）：
# sudo mkdir /Volumes/MyPassport
# 使用 ntfs-3g 命令以读写模式挂载：
# sudo /usr/local/bin/ntfs-3g /dev/disk2s1 /Volumes/MyPassport -olocal -oallow_other -o auto_xattr -ovolname=MyPassport
# 将 /dev/disk2s1 和 MyPassport 替换为你实际的设备名和卷名。

if [ $major_version -eq 17 ] ;then ntfstool_version="2.3.2"; else ntfstool_version="3.5.1";fi;
set_software_list   "ntfstool"  \
                    "/Applications/NTFSTool.app" \
                    "NTFS硬盘读写" \
                    "https://github.com/ntfstool/ntfstool" \
                    "https://github.com/ntfstool/ntfstool/releases/download/${ntfstool_version}/ntfstool${ntfstool_version}.pkg" \
                    "/"   \
                    "install_software_fun1  ntfstool"

# 使用 brew fetch --cask amorphousdiskmark 获取
# 命令运行后，你会看到类似这样的输出，其中 ==> Downloading 后面就是 .dmg 文件的直链地址


set_software_list   "SteamTools"  \
                    "/Applications/Steam++.app"  \
                    "SteamTools"  \
                    "https://github.com/SteamTools-Team/SteamTools" \
                    "https://github.com/BeyondDimension/SteamTools/releases/download/3.0.0-rc.16/Steam++_v3.0.0-rc.16_macos.dmg"   \
                    "/"   \
                    "install_software_dmg SteamTools"


# VPN
set_software_list   "Dotunnel"  \
                    "/Applications/DOTUNNEL.app"  \
                    "Dotunnel客户端"  \
                    "https://dotu.369.cyou/#" \
                    "https://share.feijipan.com/s/ZzCpWFAp"   \
                    "/"   \
                    "open_url_with_brower Dotunnel"

set_software_list  "Clash-download"  \
                    "Clash-download"  \
                    "Clash客户端导航"  \
                    "https://github.com/clash-version/clash-download" \
                    "/"   \
                    "/"   \
                    "open_url_with_brower Clash-download"

if [ $major_version -eq 17 ] ;then ClashVerge_version="1.3.0"; else ClashVerge_version="1.3.8";fi;
set_software_list  "ClashVerge"  \
                    "/Applications/Clash Verge.app"  \
                    "Clash客户端"  \
                    "https://github.com/zzzgydi/clash-verge/" \
                    "${glabal_github_proxy_url}https://github.com/zzzgydi/clash-verge/releases/download/v${ClashVerge_version}/Clash.Verge_${ClashVerge_version}_x64.dmg"   \
                    "/"   \
                    "install_software_fun1 ClashVerge"


set_software_list  "ClashVergeRev"  \
                    "/Applications/Clash Verge.app"  \
                    "Clash客户端"  \
                    "https://github.com/clash-verge-rev/clash-verge-rev" \
                    "https://share.feijipan.com/s/ZzCpWFAp"   \
                    "/"   \
                    "install_software_fun1 ClashVergeRev"

if [ $major_version -ge 18 ] ;then # 高于 macOS high Sierra
    set_software_list   "GUI.for.Clash" \
                        "/Applications/GUI.for.Clash.app" \
                        "Clash客户端" \
                        "https://github.com/GUI-for-Cores/GUI.for.Clash" \
                        "${glabal_github_proxy_url}https://github.com/GUI-for-Cores/GUI.for.Clash/releases/download/v1.9.8/GUI.for.Clash-darwin-amd64.zip" \
                        "/"   \
                        "install_software_fun1 GUI.for.Clash"
fi

set_software_list   "devpn"  \
                    "devpn"  \
                    "devpn客户端"  \
                    "https://devpn.com" \
                    "https://devpn.github.io/combo/"   \
                    "/"   \
                    "open_url_with_brower devpn"


# 插件

set_software_list "tabcopy"  \
                  "tabcopy" \
                  "谷歌浏览器插件-标签复制" \
                  "【https://tabcopy.com】【https://github.com/hansifer/tab-copy】" \
                  "https://c2.crxsoso.com/crx/blobs/AcpJF5jtlqusbifrVt6s4iLNSQXKmJRslEcQKin3jJ14N7iSq2PNpBis0qMlFxLclFi3YQ8F_pw46GAwaTxyM2cy5xybVrasV9UXRoBAkge6_9QGQ3XA6-jM9yNjlRU1GcgAxlKa5b9IMykBu0ieyupWMmcO3eScNW55/MICDLLIHGOPPMEJPECMKILGGMAAGFDMB_4_1_1_0.crx?ext=crx&filename=Tab%20Copy%204.1.1&type=dl" \
                  "/"   \
                  "open_url_with_brower tabcopy"

set_software_list "WangYiYunMusicPan"  \
                  "WangYiYunMusicPan" \
                  "谷歌浏览器插件-网易云音乐云盘管理" \
                  "" \
                  "https://c2.crxsoso.com/crx/blobs/AcpJF5jUanerA73xMEkXy3EOuLMTgQMFo7v6O93xNEnKznd8FsKHxec-_SMBWcvpCOhHVS-Zv1K3Uv7C_aHNALG3Zzc7R_X4madbLku6LfdnuGDQ0VPMPTEYnAZmQSRiNN4AxlKa5QGoinNEVOTs7Idd6F93MMaTM6AL/GNFEMFDDEADNGNFHCPBDHLGBBNOKOKCG_2_2_0_0.crx?ext=crx&filename=%E7%BD%91%E6%98%93%E4%BA%91%E9%9F%B3%E4%B9%90%E4%BA%91%E7%9B%98%E7%AE%A1%E7%90%86%202.2&type=dl" \
                  "/"   \
                  "open_url_with_brower WangYiYunMusicPan"

set_software_list "HuaChiFanYi"  \
                  "HuaChiFanYi" \
                  "谷歌浏览器插件-划词翻译" \
                  "https://chromewebstore.google.com/detail/%E5%88%92%E8%AF%8D%E7%BF%BB%E8%AF%91/ikhdkkncnoglghljlkmcimlnlhkeamad" \
                  "https://c2.crxsoso.com/crx/blobs/AcpJF5jmiDNaCnCwZY-75kt5t0UrqDu6DVNJR-PPIioBXPA0HDqCz8b-j0J-0XSCmmwA_LXMzgiKtd_Pg7Ml0mAFf9T58XgCTgbS2zonbWzRPlXQ3rPTO_Mt28zLSiVtJeW-AMZSmuXif8dBP8lBCAGqN1mIYxGUpi2NQQ/IKHDKKNCNOGLGHLJLKMCIMLNLHKEAMAD_11_6_1_0.crx?ext=crx&filename=%E5%88%92%E8%AF%8D%E7%BF%BB%E8%AF%91%2011.6.1&type=dl" \
                  "/"   \
                  "open_url_with_brower HuaChiFanYi"


set_software_list "SimpleAllowCopy"  \
                  "SimpleAllowCopy" \
                  "谷歌浏览器插件-允许复制" \
                  "https://chromewebstore.google.com/detail/simple-allow-copy/aefehdhdciieocakfobpaaolhipkcpgc" \
                  "https://c2.crxsoso.com/crx/blobs/AcpJF5jV8oE0Y9Scav2vB2KK5RnpmIyG8nNaK9FfqTbvZgHBmdNnFe1_Lng9scFMe-cNq_FZdRrQj0vjBxuvbTvpubKn8MX3tjkDuVOkdgCC0K7Itj78S8kUZbr6rItCub0AxlKa5dWmTWo4Xx4qz8e7F4A6l50on3-5/AEFEHDHDCIIEOCAKFOBPAAOLHIPKCPGC_0_8_8_0.crx?ext=crx&filename=Simple%20Allow%20Copy%200.8.8&type=dl" \
                  "/"   \
                  "open_url_with_brower SimpleAllowCopy"




# 单元测试
# set_software_list   "xtest--" \
#                     "测试---" \
#                     "测试用"  \
#                     "/"    \
#                     "/"  \
#                     "check_installed ~/.local/bin2/BBDown.config" 
# set_software_list   "xtest--" \
#                     "测试---"  \
#                     "测试用"   \
#                     "/"  \
#                     "/"  \
#                     "check_installed terminal-notifier" 

# #    / **  
# #    * 执行判断系统类型  
# #    */ 
function get_install_software_app_name(){
    xecho "Debug" "get_install_software_app_name() -- software_list_osx.sh"
    # software_offical_url=""
    software="$1"
    # file_download_url=""
    count=0
    for ((software_id = 0; software_id < ${#software_name[@]}; software_id++)); do
        # xecho "Debug" "software = $software, software_id = $software_id <=> ${software_name[$software_id]}"
        if [[ "$software" == "${software_name[$software_id]}" ]]; then  # 找到
            # software_offical_url=${software_url[$software_id]}  # 软件官网或下载地址
            # file_download_url=${software_down_url[$software_id]} # 软件指定下载地址
            # echo "${software_name[$software_id]}"  # 软件名
            echo "${software_check[$software_id]}"  # 软件检查
            # echo "${software_descriptions[$software_id]}"  # 描述
            # echo "${software_url[$software_id]}"  # 软件官网或下载地址
            # echo "${software_down_url[$software_id]}" # 软件指定下载地址
            break; # 找到，执行完则立即退出循环
        # else 
        #     xecho "Debug" "没找到 $software "
        fi
        count=$(($count+1))
    done
    # xecho "Debug" "count = $count，software_offical_url =$software_offical_url，file_download_url== $file_download_url"
    if [ $count -ge ${#software_name[@]} ]; then  # 遍历一遍没找到
        xecho "ERROR" "未知软件: $software"
        exit 1
    fi
}

function install_software_dmg() {
    xecho "DEBUG" "install_software_dmg() ---software_list_osx.sh"
    software=$1
    # file_download_url=$(get_install_software_down_url $software |tail -n 1) # 获取下载链接地址
    # xecho "DEBUG" "file_download_url =$file_download_url"

    # software_offical_url=""
    file_download_url=""
    file_md5=""
    count=0
    for ((software_id = 0; software_id < ${#software_name[@]}; software_id++)); do
        # xecho "Debug" "software = $software, software_id = $software_id <=> ${software_name[$software_id]}"
        if [[ "$software" == "${software_name[$software_id]}" ]]; then  # 找到
            # software_offical_url=${software_url[$software_id]}  # 软件官网或下载地址
            file_download_url=${software_down_url[$software_id]} # 软件指定下载地址
            file_md5=${software_file_md5[$software_id]} # 软件指定下载地址
            break; # 找到，执行完则立即退出循环
        # else 
        #     xecho "Debug" "没找到 $software "
            # xecho "Debug" "software = $software, software_id = $software_id <=> ${software_name[$software_id]}"
        fi
        count=$(($count+1))
    done
    xecho "Debug" "count =${count} ,software_offical_url =${software_offical_url}  ,file_download_url== $file_download_url"
    if [ $count -ge ${#software_name[@]} ]; then  # 遍历一遍没找到
        xecho "ERROR" "未知软件: $software"
        exit 1
    fi


    full_save_file_path2=$(download_software_file $software $file_download_url $file_md5 |tail -n 1) # 下载
    xecho "DEBUG" "full_save_file_path2 =$full_save_file_path2"
    # extract_reslut_save_path=$(auto_extract_file $full_save_file_path2 $extr2dir |tail -n 1)   # 解压到指定位置
    # xecho "DEBUG" "extract_reslut_save_path =$extract_reslut_save_path"
    TMP_DMG=$full_save_file_path2
    xecho "INFO" "挂载镜像..."
    # MOUNT_INFO=$(hdiutil attach -nobrowse "$TMP_DMG")
    MOUNT_INFO="$(hdiutil attach  "$TMP_DMG")" # 挂载镜像
    xecho "DEBUG" "MOUNT_INFO =$MOUNT_INFO"
    # MOUNT_PATH="$(echo "$MOUNT_INFO" | awk 'END {print $NF}')"
    # 修改提取挂载路径的命令：匹配包含 "/Volumes/" 的行，并提取完整路径
    MOUNT_PATH=$(echo "$MOUNT_INFO" | sed -n 's|.*\(/Volumes/[^ ]* .*\)|\1|p' | tail -1)
    xecho "DEBUG" "MOUNT_PATH =$MOUNT_PATH"
    software_check_name=$(get_install_software_app_name $software |tail -n 1) # 获取下载链接地址
    xecho "DEBUG" "software_check_name =$software_check_name"
    app_name=$(echo "$software_check_name" | awk -F'/' '{print $NF}')
    xecho "INFO" "app_name =$app_name"
    # if [ -d "$MOUNT_PATH/xxx.app" ]; then
    if [ -d "$MOUNT_PATH/$app_name" ]; then
      xecho "DEBUG" "复制应用程序..."
      xeval "cp -R '$MOUNT_PATH/$app_name' /Applications/"
      if ( check_installed "${software_check_name}" ) ; then # 检查是否安装完成，完成推出挂载
          xecho "INFO" "安装完成，推出挂载$MOUNT_PATH"
          xeval "hdiutil detach '$MOUNT_PATH' -quiet"
      fi
    elif [ -f "$MOUNT_PATH/Install.pkg" ]; then
      xecho "INFO" "安装PKG..."
      echo "sudo installer -pkg '$MOUNT_PATH/Install.pkg' -target /"
    else
      echo "未找到安装文件"
      echo "hdiutil detach '$MOUNT_PATH' -quiet"
      # rm "$TMP_DMG"
      exit 1
    fi
    
}
